//
//  LoadCtr.swift
//  soapp
//
//  Created by zhu xietong on 2017/9/5.
//  Copyright © 2017年 CocoaPods. All rights reserved.
//

import Foundation
import Eelay
import JoLoading
import soapp

//soapp 里很多控制器使用了LoadingPresenter 协议，ListController,ASListController,ColsController 这几个通用类及相关继承的类都实现了该协议。
//默认的加载显示层在SoappBuild.swift这个文件中实现        LoadingPresenterDefautLoadingClass = DefaultLoading.self//全局设置LoadingPresenter 加载控件


class LoadingCtr: UIViewController,LoadingPresenter,EeTopStyleSupport{
    
//实现该方法可替换默认的Loading层
//    var LoadingClass: JoLoading.Type{
//        get{
//            return JoLoading.self
//        }
//    }
     var initTopStyle: EeTopStyle{
        get{
            var style = EeTopStyle()
            style.navTintColor = .white
            style.statusBarStyle = .lightContent
            style.navBarBgStyle = .color(.blue)
            style.navBarBgAlpha = 1
            style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
            return style
            
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let contentV = UIView() //关键代码 要将原有添加到view 中的subview 添加到jo_contentView
        jo_contentView.eelay = [
            [contentV,[ee.X.Y],"100",100],
        ]
        view.backgroundColor = .white
        contentV.backgroundColor = .brown
        
        let item1 = UIBarButtonItem(title: "load", style: .plain, target: self, action: #selector(start))
        let item2 = UIBarButtonItem(title: "dismis", style: .plain, target: self, action: #selector(hiddenLoading))
        let item3 = UIBarButtonItem(title: "handle", style: .plain, target: self, action: #selector(faildLoading))

        self.navigationItem.rightBarButtonItems = [item1,item2,item3]
//        top_style = __demoStyle()
    }
    
    @objc func start(_ sender: UIBarButtonItem) {
        loadingV.loading()
    }
    @objc func hiddenLoading(_ sender: Any) {
        loadingV.dismiss()
    }
    @objc func faildLoading(_ sender: Any) {
        loadingV.handle(message: "请检查网络", title: "", button: "重试") {
            print("您点击了重试")
        }
    }

    
}
